package com.ws.function;
/*
方法的形参的传递机制：值传递
 */
public class ValueTransferTest3 {

    public static void main(String[] args) {

        Data data = new Data();
        data.m = 10;
        data.n = 20;

        System.out.println("m = " + data.m + ", n = " + data.n);//m = 10, n = 20

        ValueTransferTest3 test3 = new ValueTransferTest3();
        test3.swap(data);
        System.out.println("m = " + data.m + ", n = " + data.n);//m = 20, n = 10

    }

    public void swap(Data data) {
        int temp = data.m;
        data.m = data.n;
        data.n = temp;
    }
}

class Data {
    int m;
    int n;

}